package com.nciae;

import org.apache.pdfbox.multipdf.PDFMergerUtility;

import java.io.File;
import java.io.IOException;

public class Main {

    public static void main(String[] args) throws IOException {

        PDFMergerUtility mergePdf = new PDFMergerUtility();

        String folder = "C:\\Users\\k'x\\Desktop\\仲裁";
        String destinationFileName = "合并.pdf";

//        String[] filesInFolder = getFiles(folder);

//        for (int i = 0; i < filesInFolder.length; i++) {
            mergePdf.addSource(folder + File.separator + "合并测试1.pdf");
            mergePdf.addSource(folder + File.separator + "合并测试2.pdf");
//        }

        mergePdf.setDestinationFileName(folder + File.separator + destinationFileName);
        mergePdf.mergeDocuments();

        System.out.print("done");

    }

    private static String[] getFiles(String folder) throws IOException
    {
        File _folder = new File(folder);
        String[] filesInFolder;

        if(_folder.isDirectory())
        {
            filesInFolder = _folder.list();
            return filesInFolder;
        }
        else
        {
            throw new IOException("Path is not a directory");
        }
    }


}